//: src/com/silvtar/util/SSXML.java
/* 
 * Created by 朴晟宁 <piaosn@gmail.com> on 5/1/2013. 
 * Copyright (c) 2013 朴晟宁. All rights reserved.
 * 
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program;
 * 
 * *********************************************************************
 * 
 * Modify History:
 * Date        Version    Description
 * 5/1/2013   0.1        Create the class. 
 */

package com.silvtar.util;

import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

/**
 * 本类用于XML的解析。
 * 
 * @author 朴晟宁/Silvtar
 * @author piaosn@gmail.com
 * @version 0.1
 */
public class SSXML extends JFrame {
    public void buildTree(DefaultTreeModel treeModel,
            DefaultMutableTreeNode base, String xmlURI) throws IOException,
            SAXException {
        XMLReader reader = XMLReaderFactory.createXMLReader();

    }

    public static void main(String[] args) {
        try {
            if (args.length != 1) {
                System.out.println("Usage: java javaxml3.SAXTreeViewer"
                        + "[XMLReaderFactory Documents]");
                return;
            }
            SSXML viewer = new SSXML();
            viewer.setVisible(true);

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    private class SSXMLHandler implements ContentHandler {
        private DefaultTreeModel       treeModel;

        private DefaultMutableTreeNode current;

        private Locator                locator;

        public SSXMLHandler(DefaultTreeModel treeModel,
                DefaultMutableTreeNode base) {
            this.treeModel = treeModel;
            this.current = base;
        }

        @Override
        public void characters(char[] ch, int start, int length)
                throws SAXException {
            // TODO Auto-generated method stub

        }

        /**
         * end.结束解析
         */
        @Override
        public void endDocument() throws SAXException {
            // TODO Auto-generated method stub

        }

        @Override
        public void endElement(String uri, String localName, String qName)
                throws SAXException {
            // TODO Auto-generated method stub

        }

        @Override
        public void endPrefixMapping(String prefix) throws SAXException {
            // TODO Auto-generated method stub

        }

        @Override
        public void ignorableWhitespace(char[] ch, int start, int length)
                throws SAXException {
            // TODO Auto-generated method stub

        }

        @Override
        public void processingInstruction(String target, String data)
                throws SAXException {
            // TODO Auto-generated method stub

        }

        /**
         * 1.设置定位器
         */
        @Override
        public void setDocumentLocator(Locator locator) {
            this.locator = locator;

        }

        @Override
        public void skippedEntity(String name) throws SAXException {
            // TODO Auto-generated method stub

        }

        /**
         * 2.开始解析。
         */
        @Override
        public void startDocument() throws SAXException {
            // TODO Auto-generated method stub

        }

        @Override
        public void startElement(String uri, String localName, String qName,
                Attributes atts) throws SAXException {
            // TODO Auto-generated method stub

        }

        @Override
        public void startPrefixMapping(String prefix, String uri)
                throws SAXException {
            // TODO Auto-generated method stub

        }

    }

}
